import numpy as np
from sklearn.neural_network import MLPClassifier
from sklearn.metrics import confusion_matrix,classification_report

x=np.loadtxt('imgX.txt',delimiter=',')
y=np.loadtxt('labely.txt',delimiter=',')

miu=np.mean(x)
sigma=np.std(x)
x=(x-miu)/sigma

y[y==10]=0

np.random.seed(666)
a=np.random.permutation(len(x))
x=x[a]
y=y[a]

num = int(0.7 * len(x))
train_x, test_x = np.split(x, [num, ])
train_y, test_y = np.split(y, [num, ])

nn=MLPClassifier(max_iter=200)
nn.fit(train_x,train_y)

print(nn.score(test_x,test_y))
test_h=nn.predict(test_x)

print(confusion_matrix(test_y,test_h))
print(classification_report(test_y,test_h))